<?php
error_reporting(0);
$isadmin=1; 
include_once '../comm/config.php';
include_once 'include/page.class.php';
include_once '../comm/checkpostandget.php';
include_once 'check.php';

$se2=$_GET['se2']; 
$se1=$_GET['se1']; 
$keyword2=$_GET['keyword2']?$_GET['keyword2']:'%';
$px=$_GET['px'];
if($px=="")$px=9;

$fxb=$_GET['fxb'];
if($fxb==1) $where_fxb=' and fxb=1';
else $where_fxb='';

$linput=$_GET['linput']?$_GET['linput']:-999999; 
$hinput=$_GET['hinput']?$_GET['hinput']:999999999; 
$page_url="userlist.php?linput=".$linput."&hinput=".$hinput."&px=".$px;

//mysql_query("update ".$BIAOTOU."user set money=0 where money<0;");
if($se2=='ddusername'){
    $page_url.="&se2=ddusername&keyword2=".urlencode($keyword2);
	$where="where (ddusername like '%".$keyword2."%')";
}
if($se2=='dduserid'){
    $page_url.="&se2=dduserid&keyword2=".$keyword2;
	$where="where (Id = '".$keyword2."')";
}
if($se2=='tjr'){
	$sql="select Id from ".$BIAOTOU."user where ddusername='$keyword2'";
	$query=mysql_query($sql);
	$row=mysql_fetch_array($query);
	$userid=$row['Id'];
    $page_url.="&se2=tjr&keyword2=".urlencode($keyword2);
	$where="where (tjr = '".$userid."')";
}
if($se2=='qq'){
    $page_url.="&se2=qq&keyword2=".urlencode($keyword2);
	$where="where (qq like '".$keyword2."')";
}
if($se2=='tbusername'){
    $page_url.="&se2=tbusername&keyword2=".urlencode($keyword2);
	$where="where (tbusername like '".$keyword2."')";
}
if($se2=='zfb'){
    $page_url.="&se2=zfb&keyword2=".urlencode($keyword2);
	$where="where (zfb like '".$keyword2."')";
}
if($se2=='email'){
    $page_url.="&se2=email&keyword2=".urlencode($keyword2);
	$where="where (email like '".$keyword2."')";
}
if($se2=='mobile'){
    $page_url.="&se2=mobile&keyword2=".urlencode($keyword2);
	$where="where (mobile like '".$keyword2."')";
}

if($se1=='money'){
     $page_url.="&se1=money";
	 $where.=" and (money>=$linput and money<=$hinput)";
}
if($se1=='jifen'){
     $page_url.="&se1=jifen";
	 $where.=" and (jifen>=$linput and jifen<=$hinput)";
}
if($se1=='dengji'){
     $page_url.="&se1=dengji";
	 $where.=" and (dengji>=$linput and dengji<=$hinput)";
}
if($se1=='loginnum'){
     $page_url.="&se1=loginnum";
	 $where.=" and (loginnum>=$linput and loginnum<=$hinput)";
}

$page = !($_GET['page'])?'1':intval($_GET['page']);
$pagesize=10;
$page2=($page-1)*$pagesize;
if($where!='') $where=$where.$where_fxb;

if($px=="1"){$where=$where." order by money desc,id desc";}
if($px=="0"){$where=$where." order by money asc,id desc";}
if($px=="11"){$where=$where." order by jifen desc,id desc";}
if($px=="10"){$where=$where." order by jifen asc,id desc";}
if($px=="3"){$where=$where." order by loginnum desc,id desc";}
if($px=="4"){$where=$where." order by loginnum asc,id desc";}
if($px=="5"){$where=$where." order by dengji desc,id desc";}
if($px=="6"){$where=$where." order by dengji asc,id desc";}
if($px=="9"){$where=$where." order by id desc";}
$sql="select * from ".$BIAOTOU."user $where";

$rs = mysql_query($sql);
$total = mysql_num_rows($rs)?mysql_num_rows($rs):0;	
	
$sql="select * from ".$BIAOTOU."user $where limit $page2,$pagesize";
$rs = mysql_query($sql);

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理中心</title>
<link href="css/style.css" rel="stylesheet" type="text/css"></head>

<body topmargin="5" leftmargin="0">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="282" valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>
          <table cellspacing="0" width="100%" height="207" style="border:1px  solid #DCEAF7;">
            <tr>
              <td width="300" height="30" bgcolor="E9F2FB" class="bigtext"><strong>&nbsp;<img src="images/arrow.gif" width="16" height="22" align="absmiddle" /> 用户管理</strong></td>
              <form id="form1" name="form1" method="get" action="">
              <td width="580" height="30" bgcolor="E9F2FB" class="bigtext">
              <label>
              <select id="se1" name="se1">
              <option value="money">账户金额</option>
              <option value="jifen">账户积分</option>
              <option value="dengji">用户等级</option>
              <option value="loginnum">登陆次数</option>
              </select>
              </label>
              <label>
              <input type="text" style="width:30px" name="linput" /> -- <input type="text" style="width:30px" name="hinput" />&nbsp;&nbsp;
              </label>
                <label>
                <select id="se2" name="se2">  
        <option value="ddusername">用户名</option> 
        <option value="dduserid">会员ID</option>  
        <option value="tjr">推荐人名</option>       
           <option value="qq">QQ号码</option>
           <option value="zfb">支付宝号</option>
           <option value="email">邮箱</option>
           <option value="mobile">手机号码</option>
           <option value="tbusername">姓名</option>           
        </select>
        <input type="text" id="keyword" name="keyword2" />
                </label>
                            <label>
                            <input type="submit" name="Submit" value="查找" />
                            </label>
             
              </td> </form>
              <td width="187" align="right" bgcolor="E9F2FB" class="bigtext">共有 <b><?php echo $total;?></b> 条记录&nbsp;&nbsp;</td>
            </tr>
            <tr>
              <td colspan="3" valign="top"><table width="100%" height="300" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td valign="top"><table width="100%" border=1 cellpadding=0 cellspacing=0
style="border-collapse: collapse" bordercolor="#dddddd">
                  
                    <tr>
                      <td width="4%" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;ID</strong></td>
                      <td width="" height="30" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;用户名</strong></td>
                      <td width="6%" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>推荐人ID</strong></td>
                      <td width="11%" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;注册时间</strong></td>
                      <td width="13%" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;邮箱</strong></td>
                      <td width="11%" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;最近登录</strong></td>
                      <td width="7%" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;登录次数 <?php if($px=="4"){echo "<a href=\"userlist.php?$se1=".$se1."&$se2=".$se2."&keyword2=".urlencode($keyword)."&px=3\"><img src='images/up.gif' title='向下排序'/></a>";}elseif($px=="3"){echo "<a href=\"userlist.php?$se1=".$se1."&$se2=".$se2."&keyword2=".urlencode($keyword)."&px=4\"><img src='images/drop.gif' title='向上排序'/></a>";}else{echo "<a href=\"userlist.php?$se1=".$se1."&$se2=".$se2."&keyword2=".urlencode($keyword)."&px=3\"><img src='images/nochoice.gif' title='未选中'/></a>";}?></strong></td>
		               <td width="6%" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>等级  <?php if($px=="6"){echo "<a href=\"userlist.php?$se1=".$se1."&$se2=".$se2."&keyword2=".urlencode($keyword)."&px=5\"><img src='images/up.gif' title='向下排序'/></a>";}elseif($px=="5"){echo "<a href=\"userlist.php?$se1=".$se1."&$se2=".$se2."&keyword2=".urlencode($keyword)."&px=6\"><img src='images/drop.gif' title='向上排序'/></a>";}else{echo "<a href=\"userlist.php?$se1=".$se1."&$se2=".$se2."&keyword2=".urlencode($keyword)."&px=5\"><img src='images/nochoice.gif' title='未选中'/></a>";}?></strong></td>
                       <td width="6%" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;金额 <?php if($px=="0"){echo "<a href=\"userlist.php?$se1=".$se1."&$se2=".$se2."&keyword2=".urlencode($keyword)."&px=1\"><img src='images/up.gif' title='向下排序'/></a>";}elseif($px=="1"){echo "<a href=\"userlist.php?$se1=".$se1."&$se2=".$se2."&keyword2=".urlencode($keyword)."&px=0\"><img src='images/drop.gif' title='向上排序'/></a>";}else{echo "<a href=\"userlist.php?$se1=".$se1."&$se2=".$se2."&keyword2=".urlencode($keyword)."&px=1\"><img src='images/nochoice.gif' title='未选中'/></a>";}?></strong></td>
                       <td width="6%" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;积分 <?php if($px=="10"){echo "<a href=\"userlist.php?$se1=".$se1."&$se2=".$se2."&keyword2=".urlencode($keyword)."&px=11\"><img src='images/up.gif' title='向下排序'/></a>";}elseif($px=="11"){echo "<a href=\"userlist.php?$se1=".$se1."&$se2=".$se2."&keyword2=".urlencode($keyword)."&px=10\"><img src='images/drop.gif' title='向上排序'/></a>";}else{echo "<a href=\"userlist.php?$se1=".$se1."&$se2=".$se2."&keyword2=".urlencode($keyword)."&px=11\"><img src='images/nochoice.gif' title='未选中'/></a>";}?></strong></td>
					  <td width="8%" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;QQ</strong></td>
                      <td width="12%" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;执行操作</strong></td>
                    </tr>
					<?php
					while ($row = mysql_fetch_array($rs))
					{
						echo "<tr>";
                      	echo "<td align=center height=30 class=bigtext>&nbsp;".$row["Id"]."</td>";
                      	echo "<td align=center height=30 class=bigtext>&nbsp;".$row["ddusername"]."</td>";
                      	echo "<td align=center height=30 class=bigtext>&nbsp;".$row["tjr"]."</td>";
						echo "<td align=center class=bigtext>&nbsp;".$row["regtime"]."</td>";
						echo "<td align=center class=bigtext>&nbsp;".$row["email"]."</td>";
						echo "<td align=center class=bigtext>&nbsp;".$row["lastlogintime"]."</td>";
						echo "<td align=center class=bigtext>&nbsp;".$row["loginnum"]."</td>";
						echo "<td align=center class=bigtext>&nbsp;".$row["dengji"]."</td>";						
						echo "<td align=center class=bigtext>&nbsp;".round($row["money"], 2)."</td>";
						echo "<td align=center class=bigtext>&nbsp;".$row["jifen"]."</td>";
						echo "<td align=center class=bigtext>&nbsp;<a target='_blank' href='http://wpa.qq.com/msgrd?v=3&uin=".$row["qq"]."&site=qq&menu=yes'><img src='http://wpa.qq.com/pa?p=2:".$row["qq"].":46' alt='点击这里给我发消息'></a></td>";						
						echo "<td align=center align=center class=bigtext><a href=mingxi.php?username=".urlencode($row["ddusername"])." class=link4>明细</a> <a href=chguser.php?id=".$row["Id"]." class=link4>详细</a> <a href=deluser.php?id=".$row["Id"]." class=link4>删除</a></td>";
						echo "</tr>";
					}
					?></table>
					<div class="yahoo2" style=" margin-top:30px;"><?php 
				pageft($total,$pagesize,1,1,0,10,$page_url);
				echo $pagenav;?></div>
					</td>
                </tr>
              </table></td>
            </tr>
          </table></td>
        </tr>
      
    </table></td>
  </tr>
</table>
</body>
</html>
<?php mysql_close($link);?>
